package com.java12_16.learning;

/**
 * @program: jdk21-learning
 * @description:
 * @author: YuKai Fan
 * @create: 2024/8/11 17:29
 **/
public class Demo14 {

    public record Account(String username, String password) {

    }

    public static void main(String[] args) {
        Account account = new Account("admin", "123456");
        Account account1 = new Account("admin", "123456");
        System.out.println(account1.equals(account));
    }

    private static void test(String a, String b) {
        int i = a.length() + b.length();
        System.out.println(i);
    }

    class Student {
        private final String name;

        Student(String name) {
            this.name = name;
        }

        @Override
        public boolean equals(Object obj) {
            // 首先判断是否为Student类型
            if (obj instanceof Student student) {
                // 如果是，那么前置类型转换
                // 最后对比属性是否相等
                return student.name.equals(this.name);
            }
            return false;
        }
    }

}
